package org.dtrd.modules.doctor.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.doctor.entity.bean.OutpatientInfo;

import java.text.ParseException;
import java.util.Date;


/**
 * <p>
 * 
 * </p>
 *
 * @author QR
 * @since 2021-12-01 14:09:15
 */
@Getter
@Setter
@TableName("dtrd_ent_rd_outpatient")
public class DtrdEntRdOutpatient {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 医生id
     */
    private Integer doctorId;

    /**
     * 门诊日期
     */
    private Date outpatientDate;

    /**
     * 1-可预约, 0-不可预约
     */
    private Integer morningStatus;

    /**
     * 1-可预约, 0-不可预约
     */
    private Integer afternoonStatus;

    /**
     * 服务内容
     */
    private String serviceContent;

    private Date createTime;

    private Integer isDel;

    public DtrdEntRdOutpatient init() {
        isDel = 0;
        createTime = new Date();
        return this;
    }

    public DtrdEntRdOutpatient(){}

    public DtrdEntRdOutpatient(Date date, Integer doctorId) {
        this.outpatientDate = date;
        this.doctorId = doctorId;
        this.morningStatus = 0;
        this.afternoonStatus = 0;
        this.createTime = new Date();
        this.isDel = 0;
    }

    public DtrdEntRdOutpatient parseFromDto(OutpatientInfo dto) {
        doctorId = dto.getDoctorId();
        try {
            outpatientDate = DateUtils.parseDate(dto.getOutpatientDate(), DateUtils.date_sdf.get().toPattern());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        morningStatus = dto.getMorningStatus();
        afternoonStatus = dto.getAfternoonStatus();
        serviceContent = dto.getServiceContent();
        return this;
    }


}
